/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tbv_facturacionDAOImpl implements orm.dao.Tbv_facturacionDAO {
	public Tbv_facturacion loadTbv_facturacionByORMID(int fa_id_facturacion) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_facturacionByORMID(session, fa_id_facturacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion getTbv_facturacionByORMID(int fa_id_facturacion) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_facturacionByORMID(session, fa_id_facturacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByORMID(int fa_id_facturacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_facturacionByORMID(session, fa_id_facturacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion getTbv_facturacionByORMID(int fa_id_facturacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_facturacionByORMID(session, fa_id_facturacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByORMID(PersistentSession session, int fa_id_facturacion) throws PersistentException {
		try {
			return (Tbv_facturacion) session.load(orm.Tbv_facturacion.class, new Integer(fa_id_facturacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion getTbv_facturacionByORMID(PersistentSession session, int fa_id_facturacion) throws PersistentException {
		try {
			return (Tbv_facturacion) session.get(orm.Tbv_facturacion.class, new Integer(fa_id_facturacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByORMID(PersistentSession session, int fa_id_facturacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_facturacion) session.load(orm.Tbv_facturacion.class, new Integer(fa_id_facturacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion getTbv_facturacionByORMID(PersistentSession session, int fa_id_facturacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_facturacion) session.get(orm.Tbv_facturacion.class, new Integer(fa_id_facturacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion[] listTbv_facturacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_facturacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion[] listTbv_facturacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_facturacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion[] listTbv_facturacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_facturacion as Tbv_facturacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tbv_facturacion[]) list.toArray(new Tbv_facturacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion[] listTbv_facturacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_facturacion as Tbv_facturacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tbv_facturacion[]) list.toArray(new Tbv_facturacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_facturacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_facturacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tbv_facturacion[] tbv_facturacions = listTbv_facturacionByQuery(session, condition, orderBy);
		if (tbv_facturacions != null && tbv_facturacions.length > 0)
			return tbv_facturacions[0];
		else
			return null;
	}
	
	public Tbv_facturacion loadTbv_facturacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tbv_facturacion[] tbv_facturacions = listTbv_facturacionByQuery(session, condition, orderBy, lockMode);
		if (tbv_facturacions != null && tbv_facturacions.length > 0)
			return tbv_facturacions[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTbv_facturacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_facturacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_facturacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_facturacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_facturacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_facturacion as Tbv_facturacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_facturacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_facturacion as Tbv_facturacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion createTbv_facturacion() {
		return new orm.Tbv_facturacion();
	}
	
	public boolean save(orm.Tbv_facturacion tbv_facturacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().saveObject(tbv_facturacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tbv_facturacion tbv_facturacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().deleteObject(tbv_facturacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_facturacion tbv_facturacion)throws PersistentException {
		try {
			if(tbv_facturacion.getTbv_bitacora_maquinabm_id_bitacora_maquina() != null) {
				tbv_facturacion.getTbv_bitacora_maquinabm_id_bitacora_maquina().tbv_facturacion.remove(tbv_facturacion);
			}
			
			return delete(tbv_facturacion);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_facturacion tbv_facturacion, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(tbv_facturacion.getTbv_bitacora_maquinabm_id_bitacora_maquina() != null) {
				tbv_facturacion.getTbv_bitacora_maquinabm_id_bitacora_maquina().tbv_facturacion.remove(tbv_facturacion);
			}
			
			try {
				session.delete(tbv_facturacion);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tbv_facturacion tbv_facturacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().refresh(tbv_facturacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tbv_facturacion tbv_facturacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().evict(tbv_facturacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_facturacion loadTbv_facturacionByCriteria(Tbv_facturacionCriteria tbv_facturacionCriteria) {
		Tbv_facturacion[] tbv_facturacions = listTbv_facturacionByCriteria(tbv_facturacionCriteria);
		if(tbv_facturacions == null || tbv_facturacions.length == 0) {
			return null;
		}
		return tbv_facturacions[0];
	}
	
	public Tbv_facturacion[] listTbv_facturacionByCriteria(Tbv_facturacionCriteria tbv_facturacionCriteria) {
		return tbv_facturacionCriteria.listTbv_facturacion();
	}
}
